<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
    var src = 'http://localhost:8000/loading/resources/js-loaded.js?conn-type';
    var jsLoaded = false;
    var loadSuccess = false;
    if (window.internals) {
        internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections(true);
        internals.setNetworkConnectionInfoOverride(true, 'cellular3g', '4g', 100, 2.0);
        internals.evictAllResources();

        window.addEventListener('beforeunload', function() {
            internals.clearNetworkConnectionInfoOverride();
            internals.settings.setDisallowFetchForDocWrittenScriptsInMainFrameOnSlowConnections(false);
        }, false);
    }
    document.write('<scr' + 'ipt src="' + src + '" onload="loadSuccess=true"></scr' + 'ipt>');
</script>
<script>
    test(function () {
        assert_true(jsLoaded);
        assert_true(loadSuccess);
    }, "Document.written scripts are not blocked in a fast connection");
</script>
